package com.example.yadmin.sys.mapper;

import com.example.yadmin.sys.entity.Chat;
import com.example.yadmin.sys.entity.Goods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.yadmin.sys.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ag
 * @since 2023-10-13
 */
public interface GoodsMapper extends BaseMapper<Goods> {
        public List<Goods> getGoodsListInfoByUsername(@Param("username") String username);

        public List<User> getUserListInfoByOwner(@Param("goodsOwner") String goodsOwner);

        @Select("SELECT * FROM y_goods WHERE goods_name like CONCAT('%', #{goodsName}, '%')")
        public List<Goods> getGoodsByGoodsName(String goodsName);

        @Select("SELECT * FROM y_goods WHERE goods_name like CONCAT('%', #{goodsName}, '%') || " +
                "goods_owner like CONCAT('%', #{goodsOwner}, '%') ||" + "goods_desc like CONCAT('%', #{goodsDesc}, '%') ")
        public List<Goods> getGoodsBySelect(String goodsName,String goodsOwner,String goodsDesc);

        @Select("SELECT * FROM y_goods WHERE goods_price BETWEEN #{minPrice} AND #{maxPrice}")
        public List<Goods> getGoodsByPrice(BigDecimal minPrice,BigDecimal maxPrice);

        @Select("SELECT goods_id FROM y_goods WHERE goods_name = #{goodsName}")
        public Integer getGoodsIdByGoodsName(String goodsName);
}
